<%@page import="com.bluedon.ism.commons.util.Constants"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="${ctx}/js/jquery-ui/css/jquery-ui.css" type="text/css" rel="stylesheet" />
	<%@ include file="/commons/script.jsp" %>
	<script src="${ctx}/js/jquery-ui/js/jquery-ui-min.js" type="text/javascript"></script>
    <title>安全系统—用户列表</title>
<body>
<div class="m_right">   

    <div class="m_r_tips">
       <div class="m_r_lefttips">您现在的位置：<a href="${ctx}/admin/home.jsp">首页</a>&gt;系统管理&gt;账号管理</div>
       <jsp:include page="/commons/admin/admin_login_remind.jsp"/>
    </div>

	<s:form id="list_form" method="post" action="findAllPcAccount" namespace="/admin/account">
    <div class="m_r_list">
       <div class="m_r_list_pic"></div>
       <div class="m_l_list_search">关键词：
             <span class="borderHover"><s:textfield name="keywork1" id="keywork1" placeholder="用户名/登录名" cssClass="text_input_1"/>
             	所属机构：<select class="textInput2" name="orgId" id="orgId">
             		<s:iterator var="n" value="#request.orgSelectBox">
             			<option value="${n.oid}">${ n.name}</option>
             		</s:iterator>
             	</select>
		     </span>
               <a href="#" class="m_r_bnt1"><input type="submit" name="Submit" value="查询"/></a>
       </div>
    </div>
    </s:form>
    
    <s:if test="#session.DO_FEEDBACK != ''" >
           <div class="m_r_tips" style="height: auto;">
               <div class="m_r_lefttips" style="height: auto;line-height: 20px;"><span style="color:red">
                  ${DO_FEEDBACK}
                  <% session.removeAttribute("DO_FEEDBACK"); %>
               </span></div>
          </div>
    </s:if>
    
    
    
    <div class="m_r_table">

    <table width="100%" border="0" cellspacing="1" cellpadding="0">
     <thead>
          <tr>
            <td class="m_r_table_td" colspan="10" >
            <a href="${ctx}/admin/account/addPcAccount.do"><img src="${ctx}/images/list1.gif">新增</a>&nbsp;&nbsp;|&nbsp;&nbsp;
            <a href="#" id="go_del"><img src="${ctx}/images/list6.gif"/>删除</a></td>
            </tr>
          <tr>
            <td class="m_r_table_tr bold"><input type="checkbox" value=""  id="p_box"/></td>
            <td class="m_r_table_tr bold">序号</td>
            <td class="m_r_table_tr bold">登录名</td>
            <td class="m_r_table_tr bold">机构</td>
            <td class="m_r_table_tr bold">创建人</td>
            <td class="m_r_table_tr bold">创建日期</td>
            <td class="m_r_table_tr bold">上次登录时间</td>
            <td class="m_r_table_tr bold">使用状态</td>
            <td class="m_r_table_tr bold">操作</td>
          </tr>
     </thead>
   <tbody>
   <s:iterator value="pager.list"  var="acc" status="stat">
            <tr>
                    <!--  不能删除自己，不能删除系统内置用户  -->
                    <td><input type="checkbox" value="${acc.aid }" name = "s_box"  ${PC_ACCOUNT.aid == acc.aid || acc.isSystem == "true" ? "disabled = 'disabled'" : "" } /></td>
                    <td>${(pager.pageNo-1)*pager.pageSize + stat.index+1} </td>
                    <td>${acc.username}</td>
                    <td>${acc.organization.name}</td>
                    <td>
                        ${empty acc.createUser && acc.isSystem == "true" ? "系统内置" : acc.createUser.username }
                    </td>
                    <td><s:date name="#acc.createTime" format="yyyy-MM-dd HH:mm:ss"/></td>   
                    <td><s:date name="#acc.lastSigninTime" format="yyyy-MM-dd HH:mm:ss"/></td>   
                    <td>
                      <s:if test="#acc.isSystem">
                                                                                    系统内置
                      </s:if>  
                      <s:else>
                     <input type="radio" name="acc.disabled.${acc.aid}"  value="0" ${acc.disabled == false ? "checked='checked' " : ""} onclick="stopBubble(event, this);change_status('${acc.aid}',false);"/>正常  
                     <input type="radio" name="acc.disabled.${acc.aid}" value="1" ${acc.disabled == true ? "checked='checked' " : ""} onclick="stopBubble(event, this);change_status('${acc.aid}',true);">禁用  
                      </s:else>
                    </td>   
                    <td>
                      <s:if test="#acc.isSystem">
                                                                                    系统内置
                      </s:if>  
                      <s:else>
                        <a href="${ctx}/admin/account/goToAssginRole.do?aid=${acc.aid}&oid=${acc.organization.oid}&username=${acc.username}">分配角色</a> |                                                             
                        <a href="${ctx}/admin/account/editPcAccount.do?acc.aid=${acc.aid}">修改</a>                                                             
                       </s:else>
                    </td>    
          </tr>
     </s:iterator>
  </tbody>
</table>

    </div>

    <div class="pageDiv">
       <span class="pageL">共有<font color="#0e83af">${pager.totalRecord}</font>条数据</span>
       <div id="pager"></div>
   </div>


</div>

</body>



<script src="${ctx}/js/checkbox-table.js" type="text/javascript"></script>
<script type="text/javascript">

	 //加载机构
	 if ('${PC_ACCOUNT.organization.oid}' == '<%=Constants.CITY_ORG_CODE%>') {
	 	$("#orgId").prepend("<option value=''>全部</option>");
	 }
     $("#orgId").val('${orgId}');

    function change_status(aid,flag){
        var timenow = new Date().getTime(); //fuck ie
        $.get("${ctx}/admin/account/changeStatus.do?acc.disabled=" + flag + "&acc.aid=" + aid + "&d=" + timenow, function(data){
            if (data != "ok") {
                alert("操作失败");
            }
        });
    }

    $("#go_del").click(function(){
        var c = getCheckCountByName('s_box');
        if (c == 0){
          alert("请选择要删除的数据");
          return;
        }
        var change_role_values = escape(getCheckValues());
        if (window.confirm('确定删除吗')) {
            window.location.href = "${ctx}/admin/account/deletePcAccount.do?aidArray=" + change_role_values;
        }
    });

    $("#pager").pager({ pagenumber: '${pager.pageNo}', pagecount: '${pager.totalPage}', pagesize:'${pager.pageSize}', submitType:'form', formId:'list_form'});

</script>
</html>
